package com.transaction.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.transaction.domain.SysMarket;
import com.transaction.service.SysMarketService;
import com.transaction.mapper.SysMarketMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletResponse;
import java.net.URLEncoder;
import java.util.List;

/**
* @author 30600
* @description 针对表【sys_market(股票行情表)】的数据库操作Service实现
* @createDate 2024-03-26 14:15:16
*/
@Service
public class SysMarketServiceImpl extends ServiceImpl<SysMarketMapper, SysMarket>
    implements SysMarketService{

    @Autowired
    private SysMarketMapper sysMarketMapper;

    @Override
    public List<SysMarket> listExport(SysMarket sysMarket) {
        List<SysMarket> list = sysMarketMapper.listExport(sysMarket);
        return list;
    }

    @Override
    public void export(List<SysMarket> list, HttpServletResponse response) {
        try {

            response.setContentType("application/vnd.ms-excel");
            response.setCharacterEncoding("UTF-8");

            String fileName = URLEncoder.encode("股票行情数据", "UTF-8");
            response.setHeader("Content-dispostion","attachment;fileName=" + fileName + ".xlsx");

            //这里不需要关闭流


        } catch (Exception e){

        }
    }
}




